package com.specialtreasure.freightdepot.adapter;

import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.app.core.adapter.CommonAdapter;
import com.app.core.util.CommonUtil;
import com.specialtreasure.freightdepot.R;
import com.specialtreasure.freightdepot.model.ItemDetailList;


/**
 * Created by Administrator on 2017/9/1 0001.
 * 随车清单列表
 */

public class CarDetaileListAdapter extends CommonAdapter {

    private TextView tv_content;

    public CarDetaileListAdapter(FragmentActivity context) {
        super(context);
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder = null;
        if (null == view) {
            view = View.inflate(viewGroup.getContext(), R.layout.item_car_detailed_list, null);
            viewHolder = new ViewHolder(view);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        ItemDetailList itemDetail=(ItemDetailList)getItem(i);

        if (itemDetail!=null){
            viewHolder.tv_content.setText(CommonUtil.checkString(itemDetail.getArticle())+
                    itemDetail.getQuantity()+CommonUtil.checkString(itemDetail.getUnit()));

            if (itemDetail.getQuantity() == null) {
                viewHolder.tv_content.setText(CommonUtil.checkString(itemDetail.getArticle())+CommonUtil.checkString(itemDetail.getUnit()));
            }

        }

        return view;
    }


    public static class ViewHolder {
        public View rootView;
        public TextView tv_content;

        public ViewHolder(View rootView) {
            this.rootView = rootView;
            this.tv_content = (TextView) rootView.findViewById(R.id.tv_content);
        }

    }
}
